<?php
include 'checkLogin.php';

@$goodsId = $_REQUEST['goodsId'];
@$name = $_REQUEST['name'];
@$typeId= $_REQUEST['typeId'];
@$img = $_FILES['file'];
move_uploaded_file($img['tmp_name'],'img/'.$img['name']);

@$upType = $_REQUEST['upType'];

include 'db/li.php';

if($upType == 'name'){
	@$flog = dbUpdate('update goods set imgUrl=:img,name=:name,typeId=:typeId where id=:id',array('img'=>$img['name'],'name'=>$name,'typeId'=>$typeId,'id'=>$goodsId));
	if(!$flog){
		$mes = '编辑失败';
		include 'updateGoods.php';
		die;
	}
	header('Refresh:0;url=goodsList.php');
}
if($upType == 'type'){
	@$flog = dbUpdate('update type set name=:name where id=:id',array('name'=>$name,'id'=>$typeId));
	if(!$flog){
		$mes = '编辑失败';
		include 'updateType.php';
		die;
	}
	header('Refresh:0;url=typeList.php');
}
